package org.openquark.cal_Cal_Core_Prelude;
import org.openquark.cal.internal.runtime.lecc.RTExecutionContext;
import org.openquark.cal.internal.runtime.lecc.RTResultFunction;
import org.openquark.cal.internal.runtime.lecc.RTSupercombinator;
import org.openquark.cal.internal.runtime.lecc.RTValue;
import org.openquark.cal.runtime.CALExecutorException;
public final class Length extends RTSupercombinator {
/*
* CAL data instances for literal values.
*/
/**
* Singleton instance of this class.
*/
public static final Length $instance = new Length();
private Length() {
}
public final int getArity() {
return 1;
}
public final java.lang.String getModuleName() {
return "Cal.Core.Prelude";
}
public final java.lang.String getUnqualifiedName() {
return "length";
}
public final java.lang.String getQualifiedName() {
return "Cal.Core.Prelude.length";
}
/**
* f
* This method implements the function logic of the CAL function Cal.Core.Prelude.length
*/
public final RTValue f(final RTResultFunction $rootNode, final RTExecutionContext $ec) throws CALExecutorException {
// Arguments
RTValue list = $rootNode.getArgValue();
// Release the fields in the root node to open them to garbage collection
$rootNode.clearMembers();
return f1S(RTValue.lastRef(list.evaluate($ec), list = null), $ec);
}
/**
* f1L
* This method implements the function logic of the CAL function Cal.Core.Prelude.length
*/
public final RTValue f1L(RTValue list, RTExecutionContext $ec) throws CALExecutorException {
return f1S(RTValue.lastRef(list.evaluate($ec), list = null), $ec);
}
/**
* f1S
* This method implements the function logic of the CAL function Cal.Core.Prelude.length
*/
public final RTValue f1S(RTValue list, RTExecutionContext $ec) throws CALExecutorException {
// Top level supercombinator logic
return
new Length__length_Helper__2.RTAppS(
Length__length_Helper__2.$instance,
0,
list.getValue());
}
/**
* fUnboxed1S
* This method implements the logic of the CAL function Cal.Core.Prelude.length
* This version of the logic returns an unboxed value.
*/
public final int fUnboxed1S(RTValue list, RTExecutionContext $ec) throws CALExecutorException {
RTValue $result = f1S(list, $ec);
list = null;
return $result.evaluate($ec).getOrdinalValue();
}
}